﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Singleton<T> where T : class,new() {

    private static T activator;
    public static T Instance
    {
        get
        {
            if (activator == null) activator = Activator.CreateInstance<T>();
            return activator;
        }
    }
    protected Singleton()
    {
        if (null != activator)
            throw new Exception("This " + (typeof(T)).ToString() + " Singleton Instance is not null !!!");
        Init();
    }
    public virtual void Init()
    {

    }
}
